/******************************************/
/******************************************/
/****  JS Document                     ****/
/****  by Andrew Mahon                 ****/
/****  amahon@gmail.com                ****/
/******************************************/
/******************************************/

(function(tc) {

	tc.jQ.fn.y5display = function(options){
		var $y5d = this, _o = {}, _components = {}, _newestFrameDisplayed = 0
		
		_o = tc.jQ.extend({
			
		},options)
		
		function _initialize(){
			tc.util.log("YeahYeahYeahYeahYeah Display Starting",'info')
			_setup_events()
			return $y5d
		}
		
		function _setup_events(){
			tc.events.bind('cellblockFramesLoaded',_cellblockFramesLoadedHandler)
		}
		
		function _cellblockFramesLoadedHandler(e,d){
			if(d.frames){
				for(var i in d.frames){
					if(d.frames[i].wIndex > _newestFrameDisplayed){
						_newestFrameDisplayed = d.frames[i].wIndex
						$y5d.prepend('<img src="'+d.frames[i].full+'"/>')
					} else {
						$y5d.append('<img src="'+d.frames[i].full+'"/>')
					}
					
				}
			}
		}
		
		return _initialize()
	}
})(tc);